package com.good.cm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.good.cm.dao.DictMapper;
import com.good.cm.dao.ItemDictMapper;
import com.good.cm.model.ResultInfo;
import com.good.cm.vo.ItemDict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ItemDictService {

    @Resource
    private ItemDictMapper itemDictMapper;
    @Resource
    private DictMapper dictMapper;
    //@Transactional(rollbackFor = Exception.class)
    public ResultInfo getItemDict(String classCode)
    {
        ResultInfo info=new ResultInfo();
        QueryWrapper<ItemDict> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("class_code",classCode);
        List<ItemDict> dictList= itemDictMapper.selectList(queryWrapper);
        info.setResult(dictList);
        return  info;
    }

    /**
     * 获取字典
     * @param name
     * @return
     */
    public ResultInfo getDict(String name)
    {
        ResultInfo info=new ResultInfo();
        info.setResult(dictMapper.getDict(name));
        return  info;
    }
}
